<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Test Test</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="protoQ.css" type="text/css" media="screen" />
        <script type="text/javascript" src="../protoQ.js"></script>
        <script>
            var docEarly = document.readyState;

            Q.Test({
                test: [{
                    message: "Wait for DOM",
                    fn: function () {
                        return docEarly;
                    },
                    expects: "loading"

                }, {
                    fn: function () {
                        var states = ["loaded", "interactive", "complete"]; 
                        return (states.indexOf(document.readyState) > -1);
                    },
                    expects: true
                }]
            });

            Q.Test({
                test: {
                    message: "Test multiton",
                    fn: function () {
                        return (Q.Test.instance.length > 0);
                    },
                    expects: true
                }
            });

            Q.Test({
                test: {
                    message: "Fake test fail",
                    fn: function () {
                        return false;
                    },
                    expects: true
                }
            });

            Q.Test({
                test: [{
                        message: "Fake module test fail",
                        fn: function () {
                            return true;
                        },
                        expects: true
                    }, {
                        fn: function () {
                            return true;
                        },
                        expects: true
                    }, {
                        fn: function () {
                            return {fake: "test"};
                        },
                        expects: ["fake", "test"]
                    }, {
                        fn: function () {
                            return true;
                        },
                        expects: true
                    }]
            });

            Q.Js({fn: function () {
                    var doc = document,
                    resultsElm = doc.getElementById("results"),
                    title = doc.getElementById("test-header"),
                    li, status, message, tests = Q.Test.instance,
                    user = doc.getElementById("userAgent"),
                    stop = 1, expected, results;
                    user.textContent = window.navigator.userAgent;
                    title.textContent = doc.title;
                    tests.forEach(function (test) {
                        li = doc.createElement("LI");
                        status = test.status;
                        if (test.config.test.length) {
                            message = test.config.test[0].message;
                            stop = test.results.length;
                            expected = test.config.test[stop - 1].expects;
                            results = test.results[stop - 1];
                        } else {
                            message = test.config.test.message;
                            expected = test.config.test.expects;
                            results = test.results;
                        }
                        li.setAttribute("class", status);
                        message += " ... " + status
                        if (status === "failed") {
                            message += " (#" + stop || "";
                            message += " expected: " + JSON.stringify(expected) + ", ";
                            message += " results: " + JSON.stringify(results) + ")";
                        }
                        li.textContent = message;
                        resultsElm.appendChild(li);
                    });
                }
            });

            Q.start();
        </script>
    </head>
    <body>
        <h1 id="test-header"></h1>
        <h2 id="userAgent"></h2>
        <ol id="results"></ol>
    </body>
</html>
